package com.example.xinyun.domain;

import com.example.xinyun.MyApplication;
import ohos.data.DatabaseHelper;
import ohos.data.preferences.Preferences;

public class DataBase {
    public static String readUser(String key){
        String username;
        DatabaseHelper databaseHelper = new DatabaseHelper(MyApplication.homeContext);
        Preferences preferences = databaseHelper.getPreferences("user");
        username = preferences.getString(key,"");
        return username;
    }

    public static void writeUser(String key,String value){
        DatabaseHelper databaseHelper = new DatabaseHelper(MyApplication.homeContext);
        Preferences preferences = databaseHelper.getPreferences("user");
        preferences.putString(key, value).flushSync();
    }
}
